﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;

namespace TaskSchedulingSystemClassLibrary.DataModel
{
    [XmlRoot("appConfig")]
    public class appConfig 
    {
        [XmlElement("TaskType")]
        public List<TaskType> allTaskType { set; get; }
    }
    public class TaskType
    {
        [XmlAttribute("TypeName")]
        public string TypeName { set; get; }

        [XmlElement("task")]
        public List<TaskModel> taskLst { set; get; }
    }
    public class TaskModel : NotifyPropertyChangedViewModel
    {
        
        /// <summary>
        /// 任务类名
        /// </summary>
        [XmlAttribute("taskClass")]
        public string taskClass { set; get; } 
        /// <summary>
        /// 任务id
        /// </summary>
        [XmlAttribute("taskId")]
        public int taskId { set; get; }
        /// <summary>
        /// 任务名称
        /// </summary>
        [XmlAttribute("taskName")]
        public string taskName { set; get; }
        /// 星期几
        /// </summary>
        [XmlAttribute("weekDay")]
        public string weekDay { set; get; }
        /// <summary>
        /// 任务执行时间
        /// </summary>
        [XmlAttribute("carryTime")]
        public string carryTime { set; get; }
        /// <summary>
        /// 该任务是否触发
        /// </summary>
        [XmlIgnore()]
        public bool isRunTask { set; get; }
        /// <summary>
        /// 任务程序集信息
        /// </summary>
        [XmlElement("taskDll")]
        public DllInfoModel taskDll { set; get; }
        /// <summary>
        /// 任务执行时输出的文本
        /// </summary>
        [XmlIgnore()]
        public string taskContext { set; get; }
        /// <summary>
        /// 任务执行时的线程id
        /// </summary>
        [XmlIgnore()]
        public int taskThreadId { set; get; }

        public string TaskContext
        {
            get { return this.taskContext; }
            set
            {
                if(this.taskContext != value)
                {
                    this.taskContext += value;
                    this.PropertyChanged += PropertyChangedEvent;
                    this.OnPropertyChanged("TaskContext");                    
                }
            }

        }
        public static void PropertyChangedEvent(object sender, PropertyChangedEventArgs e)
        {
            //Console.WriteLine("调用处理事件");
        }
    }
    public class DllInfoModel
    {
        /// <summary>
        /// 任务程序集名称
        /// </summary>
       [XmlAttribute("dllName")]
        public string dllName { set; get; }
        /// <summary>
        /// 任务程序集路径
        /// </summary>
        [XmlAttribute("dllPath")]
        public string dllPath { set; get; }
    }
    public class XmlInfoModel
    {
        /// <summary>
        /// 任务数据配置文件名称
        /// </summary>
        [XmlAttribute("xmlName")]
        public string xmlName { set; get; }
        /// <summary>
        /// 任务数据配饰文件路径
        /// </summary>
        [XmlAttribute("xmlPath")]
        public string xmlPath { set; get; }

    }
    public class IOControlModel
    {
        /// <summary>
        /// 当前正在请求输入输出的任务的id
        /// </summary>
        public int carryingTaskId { set; get; }
        /// <summary>
        /// 此刻的输入输出请求是否已经执行完毕
        /// </summary>
        public bool isEnd { set; get; }
        /// <summary>
        /// 当前要输入的内容
        /// </summary>
        public string value { set; get; }

    }
}
